<?php
namespace app\common\command;

use app\common\lib\AMQP;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\console\input\Argument;
use think\console\input\Option;

/**
 * AMQP worker
 * Class AMQPWorker
 * @package app\common\command
 */
class AMQPWorker extends Command
{
    /**
     * 命令配置
     */
    protected function configure()
    {
        $this->setName('amqp:worker')
            ->setDescription('AMQP Worker')
            ->addOption('queue', null, Option::VALUE_OPTIONAL, 'the options');
    }

    /**
     * 执行命令
     * @param Input $input
     * @param Output $output
     * @return int|void|null
     * @throws \think\Exception
     */
    protected function execute(Input $input, Output $output)
    {
        $queue = $input->getOption('queue') ?? 'task';

        (new AMQP())->worker($queue);
    }
}
